package com.zl.easybuy.vo;

import lombok.Getter;

import java.util.List;

/**
 * 响应给前台的统一数据对象
 * 泛型类
 */
@Getter
public class ResultVO<T> {
    private int code;   //状态码
    private String msg; //消息
    private List<T> datas; // 返回给前台的数据

    public ResultVO(ResultCode resultCode,List<T> datas){
        this.code = resultCode.getCode();
        this.msg = resultCode.getMsg();
        this.datas = datas;
    }

    //正常响应
    public ResultVO(List<T> datas){
        this(ResultCode.SUCCESS,datas);
    }
    //正常响应，不响应数据
    public static  ResultVO success(){
        return new ResultVO(null);
    }
    //失败响应
    public  static  ResultVO returnFail(ResultCode resultCode){
        return new ResultVO(resultCode,null);
    }
}
